package com.mactivity.helper;
/**
 * Author : Sanjay Vasudeva
 * Class TimeConverterHelper has one function which converts time from 24:00:00 to 6am-11am to 12pm tp 11pm format.
 * **/
public class TimeConverterHelper {
	//Function which converts database time to am-pm format
	public String ConvertTimeToAmPm(String time){
		String returnTimeHour=null;
		try
		{
			String timeHour=time.substring(0,2);
			String strTimeHour=timeHour.toString();
			int iHour=Integer.parseInt(strTimeHour);
			String strHourPm = null;		
			//retain ams
			if(iHour < 12){
				strHourPm = Integer.toString(iHour);
				returnTimeHour=strHourPm+"am";
			}
			//12pm
			else if(iHour == 12){
				returnTimeHour=timeHour+"pm";
			}
			// Midnight (though its not used in app)
			else if(iHour == 0){
				returnTimeHour="12am";
			}
			//1-11pm
			else{
				int iHourPm=iHour-12;
				strHourPm = Integer.toString(iHourPm);
				returnTimeHour=strHourPm+"pm";
			}
		}
		catch(Exception e)
		{
			e.printStackTrace();
		}
		return returnTimeHour;
	}
}
